package com.twu.biblioteca.resources;

import com.twu.biblioteca.Session;

/**
 * Created with IntelliJ IDEA.
 * User: arvind
 * Date: 11/10/13
 * Time: 5:13 PM
 * To change this template use File | Settings | File Templates.
 */
public class Menu {

    private static Menu menuInstance=new Menu();

    private static String[] menuItems={"View Books","Reserve a Book","MembershipDetails","View Movies","Login"};

    private Menu(){}

    public static  Menu getInstance()
    {
        return menuInstance;
    }
    private String[] getMenuItems()
    {
        return  menuItems;
    }

    private int getEndValue(Session session) {

        int endValue;
        if(session.isLoginStatus())
            endValue=menuItems.length-1;
        else
            endValue=menuItems.length;

        return endValue;
    }

    public String displayMenu(Session session) {

        String[] menuItems=getMenuItems();
        int endValue=getEndValue(session);
        StringBuffer response=new StringBuffer();
        for(int i=0;i<endValue;i++)
            response.append((i+1)+". "+menuItems[i]+"\n");

        return response.toString();

    }

}
